﻿
using System;
using System.Device.Location;
using System.ComponentModel;

namespace OttawaTourMap.Models
{
    /// <summary>
    /// Represents a pushpin data model.
    /// </summary>
    public class PushpinModel : INotifyPropertyChanged
    {

        private string _pushpinStyle;
        public string PushpinStyle
        {

            get
            {
                return "PushpinStyle_visited";
            }
        }
        private string _visited;
        public string Visited
        {
            get
            {
                return _visited;
            }
            set
            {
                if (!value.Equals(_visited))
                {
                    _visited = value;
                    NotifyPropertyChanged("Visited");
                }
            }
        }

        private string _opacity;
        public string Opacity
        {
            get
            {
                return _opacity;
            }
            set
            {
                if (!value.Equals(_opacity))
                {
                    _opacity = value;
                    NotifyPropertyChanged("Opacity");
                }
            }
        }

        private bool _isUserLocation;
        private GeoCoordinate _location;

        public bool isUserLocation { get; set; }
        /// <summary>
        /// Gets or sets the pushpin location.
        /// </summary>
        public GeoCoordinate Location { 
            get
            {
                return _location;
            }
            set
            {
                if (!value.Equals(_location))
                {
                    _location = value;
                    NotifyPropertyChanged("Location");
                }
            }
        }

        private string text;

        public string Text
        {
            get
            {
                return text;
            }

            set
            {
                if (!value.Equals(text))
                {
                    text = value;
                    NotifyPropertyChanged("Text");
                }
            }
        }
        /// <summary>
        /// Gets or sets the pushpin icon uri.
        /// </summary>
        private Uri _icon;
        public Uri Icon
        {
            get
            {
                return _icon;
            }
            set
            {
                if (!value.Equals(_icon))
                {
                    _icon = value;
                    NotifyPropertyChanged("Icon");
                }
            }
        }

        /// <summary>
        /// Gets or sets the pushpin type name.
        /// </summary>
        public string TypeName { get; set; }

        /// <summary>
        /// Marks whether the tour stop has already been visited
        /// </summary>
        public bool isVisited { get; set; }

        /// <summary>
        /// The id of the tour stop
        /// </summary>
        public int tourStopId { get; set; }

        public PushpinModel Clone(GeoCoordinate location)
        {
            return new PushpinModel
            {
                Location = location,
                TypeName = TypeName,
                Icon = Icon,
                isUserLocation = false,
                isVisited = false,
                tourStopId = tourStopId,
                Visited  = Visited,
                Opacity = Opacity
            };

       }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
